package com.shop.ken.service.impl;

import com.shop.ken.entity.dao.AmsUserMapper;
import com.shop.ken.entity.model.AmsUser;
import com.shop.ken.entity.model.AmsUserExample;
import com.shop.ken.service.AmsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目名称：shop-server
 * 文件名称：AmsUserServiceImpl
 * 日期：2017/9/7
 * Copyright ©2017, 广州职赢未来信息科技有限公司 All Rights Reserved.\
 * <p>
 * <p>
 * 功能描述：用户信息表实现类
 * 创建人: 霍梓潮
 * 创建时间：2017/9/7
 **/
@Service
public class AmsUserServiceImpl implements AmsUserService{
    @Autowired
    private AmsUserMapper mapper;


    /**
     * 根据帐号密码，获取登陆人信息
     *
     * @param username
     * @param password
     * @return com.shop.ken.entity.model.AmsUser
     * @author 霍梓潮
     * @Date 2017-09-07 09:55:18
     */
    @Override
    public AmsUser getUser(String username, String password) {
        AmsUserExample ex = new AmsUserExample();
        ex.createCriteria().andAcountEqualTo(username).andPasswordEqualTo(password);
        List<AmsUser> list =  mapper.selectByExample(ex);
        if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
